<?php $this->pageTitle=Yii::app()->name; 
$this->breadcrumbs=array(
	'图书'=>array('/book'),
	$book->name,
	
);?>
<?php 
cs()->registerCssFile(bu().'/css/jquery.tooltip.css');
cs()->registerCoreScript('jquery');
cs()->registerScriptFile(bu().'/javascript/jquery.bgiframe.js');
cs()->registerScriptFile(bu().'/javascript/jquery.dimensions.js');
cs()->registerScriptFile(bu().'/javascript/jquery.tooltip.js');
?>
<div class='span-16 colborder article' id='article_detail'>
   <h3><?=$book->name?></h3>
   <div class='span-4' id='book_detail_img'>
		<?php $imageurl = bu().'/attachment/bookcover/small/'.substr($book->small_pic,strrpos($book->small_pic,'/')); ?>
		<?=CHtml::image($imageurl,$book->name);?>
   </div>
   <div class='span-7' id='book_detail_des'>
		<ul>
			<li>作者：<?=$book->author?></li>
			<li>ISBN：<?=$book->ISBN?></li>
			<li>页数：<?=$book->pages?></li>
			<li>市场价：<?=$book->market_price?></li>
			<li>出版社：<?=$book->publish?></li>
			<li>装帧：<?=$book->package?></li>
			<li>开本：<?=$book->format?></li>
			<li>纸张：<?=$book->paper?></li>
			<li>出版年：<?=date('Y年',$book->publish_datetime)?></li>
		</ul>
   </div>
   <div class='span-4  last'>
		<!--放置评分结果-->
   </div>
   <div class='span-16 prepend-top' id='book_detail_score'>
   <?php 
   if(!user()->isGuest&&($vote=UrVote::model()->find('uid=:uid and bid=:bid',array('uid'=>user()->id,'bid'=>$book->id)))!==null){
?>

<?php
			echo $vote->readTag."&nbsp;&nbsp;".l('删除','javascript:;',array('onclick'=>"
			$.ajax({
				url:'".$this->createUrl('/urVote/delete')."',
				type:'post',
				data:'uid=".user()->id."&bid=".$book->id."',
				success:function(data){
					if(data==1){
						window.location.reload();
						}
					}
				});
			"));
			
			if($vote->desire==3){
				echo "<br/>评价：";
				for($i=1;$i<$vote->rate;$i++){
					echo CHtml::image(image().'/site/sth.gif');
					}
				}
	}else{
   ?>
		<ul>
			<li><?=l('想读','javascript:;',array('onclick'=>"$.ajax({
				url:'".$this->createUrl('/urVote/add')."',
				type:'POST',
				data:'bid=".$book->id."&rate=0&desire=1&ajax=1',
				success:function(data){
					if(data==1){
						window.location.reload();
						}else{
						alert('您可能还没有登录，请在页面右上方进行登录');
						}
					}
				})"))?></li>
			<li><?=l('在读','javascript:;',array('onclick'=>"$.ajax({
				url:'".$this->createUrl('/urVote/add')."',
				type:'POST',
				data:'bid=".$book->id."&rate=0&desire=2&ajax=1',
				success:function(data){
					if(data==1){
						window.location.reload();
						}else{
						alert('您可能还没有登录，请在页面右上方进行登录');
						}
					}
				})"))?></li></li>
			<li class='hasread'><?=l('读过','javascript:;',array('onclick'=>"alert('请点击右侧对图书进行评价');"))?>
			<span id="stars"><span>评价：</span>
			<!--sth.gif-->
			<a href="#"><img id="star1" src="<?=image()?>/site/nst.gif"></a>
			<a href="#"><img id="star2" src="<?=image()?>/site/nst.gif"></a>
			<a href="#"><img id="star3" src="<?=image()?>/site/nst.gif"></a>
			<a href="#"><img id="star4" src="<?=image()?>/site/nst.gif"></a>
			<a href="#"><img id="star5" src="<?=image()?>/site/nst.gif"></a>
			<?=CHtml::hiddenField('bookid',$book->id)?>
			<?=CHtml::hiddenField('isguest',user()->isGuest)?>
			
			<div class='clr'></div>
			<?php cs()->registerScript('rate1',"
			$('#stars a').mouseover(function(){
				$('#stars a').children('img').attr('src','".image()."/site/nst.gif');
				id=$(this).children('img').attr('id');
				index=id.substring(4,5);
				for(i=1;i<=index;i++){
					$('#star'+i).attr('src','".image()."/site/sth.gif');
					}
				}).click(function(){
					if($('#isguest').val()==1){
						alert('您可能还没有登录，请先登录');
						window.location.href='".$this->createUrl('user/login')."';
					}
					title = '我读过这本书';
					$('#floatlayout_title').empty().append(title);
					index = $(this).children('img').attr('id').substring(4,5);
					bid = $('#bookid').val();
					html='评价：';
					for(i=1;i<=index;i++){
						html+='<img src=\'".image()."/site/sth.gif\'/>';
						}
					html+='&nbsp;&nbsp;('+index+'星)';
					html+='".CHtml::beginForm($this->createUrl('/urVote/add'),'post')."';
					html+='<input type=hidden name=rate value='+index+'>';
					html+='<input type=hidden name=bid value='+bid+'>';
					html+='<input type=hidden name=desire value=3 ><br>';
					html+='<input type=submit name=submit value=提交 >';
					html+='".CHtml::endForm()."';
					$('#floatlayout_content').empty().append(html);
					$('#floatlayout').fadeIn();
					});
			")?>
			</span>
			</li>
		</ul><br/>
		<?php } ?>
		<br/>
		
		<?=l('希望图书馆收藏此书','javascript:;',array('style'=>'width:160px;','id'=>'libcollect_box','onclick'=>"$.ajax({
			url:'".$this->createUrl('/urBookLib/bookLibBox')."',
			type:'POST',
			data:'step=1&bid=".$book->id."',
			success:function(data){
				if(data=='guest'){
					alert('您可能还没有登录，请先登录');
					window.location.href='".$this->createUrl('user/login')."';
				}
				$('#floatlayout_title').empty().append('希望图书馆收藏此书');
				$('#floatlayout_content').empty().append(data);
				$('#floatlayout').fadeIn();
				}
			})"))?>
			
		<span class='floatright addreview'><?=l(CHtml::image(image().'site/add-review.gif').'写书评('.UrComment::model()->count('bid=:bid',array(':bid'=>$book->id)).')',$this->createUrl('/comment/add',array('id'=>$book->id)),array())?></span>
   </div>
   <div class='span-16 prepend-top'></div>
 <hr/>
   <div class='span-16 prepend-top' id='book_detail_intro'>
		<h2>简介</h2>
		<p><?=$book->extra->book_intro?></p>
		<h2>作者介绍</h2>
		<p><?=$book->extra->author_intro?></p>
   </div>
 <hr/>
 	<div class='span-16' id='book_comment'>
 		<h2 class='green'>书评</h2>
 		<?php $this->widget('application.components.BookComment',array('bid'=>$book->id,'num'=>5));?>
	 	<?php $totalCommentNum = UrComment::model()->count('bid=:bid',array(':bid'=>$book->id));
	 	if($totalCommentNum > 5){
	 		?>
	 	<span style='float:right;'><?=l('查看全部('.$totalCommentNum.')>>>',array('/comment/list','type'=>1,'bid'=>$book->id))?></span>	
	 	<?php
	 	}
	 	?>
 	</div>
 	

</div>
<div class='span-6'>
	<?php
$this->widget('application.components.CollectionList',array('num'=>5));
$this->widget('application.components.CommentList',array('num'=>10));
?>
</div>
<div class='span-1 last'></div>
<?=$this->renderPartial('application.views.layouts.floatlayout');?>
